#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   02-security-run.sh
# Version:    1.0
# Date:       2020/04/24
# Author:     Lz
# Email:      lz843723683@163.com
# History：     
#             Version 1.0, 2020/04/24
# Function:   Security - 安全se
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
ScrtClean_FTGW_RUN(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
ScrtExit_FTGW_RUN(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
ScrtUSAGE_FTGW_RUN(){
	USAGE_FTLIB "金风服务器运行版 - 安装形态se"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
ScrtInit_FTGW_RUN(){
        # 调用初始化函数
	Init_FTLIB "ScrtClean_FTGW_RUN"
        # 调用用户界面函数
 	ScrtUSAGE_FTGW_RUN
}


## TODO ：Se 安全默认为disabled
#
ScrtTest01_FTGW_RUN(){
	local flag="disabled"
	local field="SELINUX="

	# 使用getenforce判断
	echo -n " getenforce : "
	getenforce
	getenforce | grep -q -i "${flag}" 
        RetParse_FTLIB "Se 默认为 ${flag} " "False"

#	# 判断se配置文件,需要安全管理员故阻塞
#	local cfgfile="/etc/sysconfig/selinux"
#	echo 'cat' "${cfgfile}"
#	cat ${cfgfile} | grep "^${field}"
#	cat ${cfgfile} | grep "^${field}" | grep -i -q ${flag}
#        RetParse_FTLIB "${cfgfile} 默认配置为 ${flag} " "False"
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
ScrtMain_FTGW_RUN(){
	ScrtInit_FTGW_RUN

	ScrtTest01_FTGW_RUN

	return ${TPASS}	
}

ScrtMain_FTGW_RUN
ScrtExit_FTGW_RUN $?
